package com.gxa.meiye.admin.platform.controller;

import com.gxa.meiye.admin.platform.pojo.vo.*;
import com.gxa.meiye.admin.platform.service.OrderManageService;
import com.gxa.meiye.admin.platform.service.ServiceManageService;
import com.gxa.meiye.core.common.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api
@RestController
@RequestMapping("/platform/servicemanage")
public class ServicemanageController {
    @Resource
    private ServiceManageService serviceManageService;
    private OrderManageService orderManageService;
    @ApiOperation("服务管理（点击服务管理渲染）")
    @GetMapping("/servicemanage/queryAll")
    public Map queryAll(){
        List<ServiceManageVo> serviceManageVos = this.serviceManageService.queryAll();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(serviceManageVos);
        jsonResult.setMsg("查询成功");
        return jsonResult.getMap();
    }
    @ApiOperation("搜索服务管理")
    @PostMapping("/servicemanage/selectAll")
    public Map selectAll(@RequestBody SelectServiceVo selectServiceVo){
        List<ServiceManageVo> serviceManageVos = this.serviceManageService.selectAll(selectServiceVo.getStatus(), selectServiceVo.getTempall());
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(serviceManageVos);
        jsonResult.setMsg("查询成功");
        return jsonResult.getMap();
    }
    @ApiOperation("详情")
    @PostMapping("/servicemanage/detailsAll")
    public Map detailsAll(Integer id){
        List<ProjectMationVo> projectMationVos = this.serviceManageService.queryProject(id);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(projectMationVos);
        jsonResult.setMsg("查询成功");
        return jsonResult.getMap();
    }
    @ApiOperation("屏蔽")
    @PostMapping("/servicemanage/updateStatus")
    public Map updateStatus(Integer id){
        if(id == 1) {
            this.serviceManageService.updateStatus(id);
        } else if(id==3){
            this.serviceManageService.updateStatus1(id);
        }
        List<ServiceManageVo> serviceManageVos = this.serviceManageService.queryAll();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(serviceManageVos);
        jsonResult.setMsg("修改成功");
        return jsonResult.getMap();
    }
    @ApiOperation("敏感词管理（点击敏感词管理渲染）")
    @GetMapping("/servicemanage/querywordAll")
    public Map querywordAll(){
        List<WordManageVo> wordManageVos = this.serviceManageService.querywordAll();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(wordManageVos);
        jsonResult.setMsg("查询成功");
        return jsonResult.getMap();
    }
    @ApiOperation("新增敏感词")
    @PostMapping("/servicemanage/addWord")
    public Map addWord(String word){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf.format(new Date());
        this.serviceManageService.addWord(word,format);
        List<WordManageVo> wordManageVos = this.serviceManageService.querywordAll();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(wordManageVos);
        jsonResult.setMsg("操作成功");
        return jsonResult.getMap();
    }
    @ApiOperation("搜索关键词")
    @PostMapping("/servicemanage/selectWord")
    public Map selectWord(String word){
        List<WordManageVo> wordManageVos = this.serviceManageService.selectWord(word);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(wordManageVos);
        jsonResult.setMsg("查询成功");
        return jsonResult.getMap();
    }
    @ApiOperation("编辑")
    @PostMapping("/servicemanage/updateWord")
    public Map updateWord(@RequestBody WordAddVo wordAddVo){
        this.serviceManageService.updateWord(wordAddVo.getId(),wordAddVo.getWord());
        List<WordManageVo> wordManageVos = this.serviceManageService.querywordAll();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(wordManageVos);
        jsonResult.setMsg("修改成功");
        return jsonResult.getMap();
    }
    @ApiOperation("删除")
    @PostMapping("/servicemanage/deleteWord")
    public Map deleteWord(Integer id){
        this.serviceManageService.deleteWord(id);
        JsonResult jsonResult = new JsonResult();
        List<WordManageVo> wordManageVos = this.serviceManageService.querywordAll();
        jsonResult.setCode("200");
        jsonResult.setData(wordManageVos);
        jsonResult.setMsg("修改成功");
        return jsonResult.getMap();
    }






}
